import 'package:flutter/material.dart';
import 'package:sample2/components/notification/user_info.dart';
import 'package:sample2/pages/chat/chat.dart';
import 'package:sample2/pages/profile/profile.dart';

class MySideMenu extends StatelessWidget {
  const MySideMenu({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: MediaQuery.of(context).size.width * 0.4,
      height: MediaQuery.of(context).size.height,
      decoration: const BoxDecoration(color: Colors.white),
      child: ListView(
        padding: EdgeInsets.zero,
        children: [
          const DrawerHeader(
            decoration:
                BoxDecoration(color: Colors.red, shape: BoxShape.rectangle),
            child: Text(
              "Side Menus",
            ),
          ),
          ListTile(
            title: const Text("HomePage"),
            onTap: () {
              Navigator.of(context).pop();
            },
          ),
          ListTile(
            title: const Text("Go to Chat with index 1"),
            onTap: () {
              //pass tab index
              Navigator.popAndPushNamed(context, "/chat",
                  arguments: ChatRouterParameter(index: 1));
            },
          ),
          ListTile(
            title: const Text("Samples"),
            onTap: () {
              Navigator.popAndPushNamed(context, "/samples");
            },
          ),
          ListTile(
            title: const Text("Profile"),
            onTap: () {
              Navigator.of(context).pop();
              Navigator.of(context).push(
                MaterialPageRoute(
                    builder: (BuildContext context) {
                      return const Profile();
                    },
                    fullscreenDialog:
                        false), //fullscreenDialog 設置成true可以變成modal形式
              );
            },
          ),
          ListTile(
            title: const Text("Settings"),
            onTap: () {
              Navigator.of(context).popAndPushNamed("/settings");
            },
          ),
          ListTile(
            title: const Text("Logout"),
            onTap: () {
              LogoutActionNotification("Are you sure you wanna logout?")
                  .dispatch(context);
            },
          ),
        ],
      ),
    );
  }
}
